// 字段显示设置
import FieldSettingDialog from '@sourcing/components/fieldSettingDialog';
import { getTableColumnsService } from '@/api/sourcing/public';
export default {
  components: {
    FieldSettingDialog,
  },
  data () {
    return {
      fieldSettingVisible: false,
    }
  },
  methods: {
    // 字段显示设置
    fieldSettingHandler () {
      this.fieldSettingVisible = true;
    },
    async getTableColumns () {
      const parmas = {
        menuId: sessionStorage.getItem('menuId'),
        isShow: 1
      }
      const res = await getTableColumnsService(parmas, state => { this.tableInfo.loading = state })
      if (res) {
        this.tableInfo.columns = this.formatTableColumns(res.data);
      }
    },
    formatTableColumns (columns) {
      columns.map((item) => {
        if (item.prop == 'expectInquiryDatetimeStr') {
          item.render = (h, { row }) => (
            row.timelyStr == '超时' ? <el-link type="warning">{row.expectInquiryDatetimeStr}</el-link> : <span>{row.expectInquiryDatetimeStr}</span>
          )
        }
        if (item.prop == 'requireArrivalDatetime') {
          item.render = (h, { row }) => (
            row.timelinessOrder == '超时' ? <el-link type="warning">{row.requireArrivalDatetime}</el-link> : <span>{row.requireArrivalDatetime}</span>
          )
        }
        if (item.prop == 'fileGroupId') {
          item.render = (h, { row }) => (
            row.fileGroupId && row.fileGroupId != '0' ? <el-link onClick={() => this.queryGoodsQualificationsAction(row)} type="primary">查看附件</el-link> : ''
          )
        }
      });
      return columns;
    }
  }
}
